/*
* Copyright (C) Microsoft. All rights reserved.  
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not 
* use this file except in compliance with the License.  You may obtain a copy 
* of the License at http://www.apache.org/licenses/LICENSE-2.0  
* 
* THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED 
* WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, 
* MERCHANTABLITY OR NON-INFRINGEMENT. 
*
* See the Apache License, Version 2.0 for specific language governing 
* permissions and limitations under the License.
*
*/
#pragma once

#include <baja/common.hpp>
#include <baja/vars.hpp>

namespace journal {

namespace b = baja;

struct isettings_service_observer : public b::ibase
{
    BAJA_INTERFACE_NOTAG(isettings_service_observer);

    virtual void onBeforeSettingChange(const b::wchar* fullName) = 0;
    virtual void onAfterSettingChange(const b::wchar* fullName) = 0;
};

struct isetting_base : public b::ibase
{
    BAJA_INTERFACE_NOTAG(isetting_base)

    virtual std::wstring name() = 0;
    virtual void reset() = 0;
    virtual void* getValueBuffer() = 0;
    virtual b::uint32 getValueBufferSize() = 0;
};

struct ibool_setting : public b::ibase
{
    BAJA_INTERFACE_NOTAG(ibool_setting)

    virtual bool getValue() = 0;
    virtual void setValue(bool value) = 0;
};

struct iint_setting : public b::ibase
{
    BAJA_INTERFACE_NOTAG(iint_setting)

    virtual int getValue() = 0;
    virtual void setValue(int value) = 0;
};

struct ifloat_setting : public b::ibase
{
    BAJA_INTERFACE_NOTAG(ifloat_setting)

    virtual float getValue() = 0;
    virtual float getMinValue() = 0;
    virtual float getMaxValue() = 0;
    virtual float getChangeStep() = 0;
    virtual void setValue(float value) = 0;
};

struct ienum_setting : public b::ibase
{
    BAJA_INTERFACE_NOTAG(ienum_setting)

    virtual int getValue() = 0;
    virtual void setValue(int value) = 0;
};

struct isettings_service : public b::ibase
{
    BAJA_INTERFACE(isettings_service, "3E47AA0A-16C9-42C7-8DDE-B983A974D455")

    virtual void registerBool(
        const int id,
        const b::wchar* name, 
        const bool defaultValue
        ) = 0;

    virtual void registerInt(
        const int id,
        const b::wchar* name,
        const int minValue,
        const int maxValue,
        const int changeStep,
        const int defaultValue
        ) = 0;

    virtual void registerFloat(
        const int id,
        const b::wchar* name,
        const float minValue,
        const float maxValue,
        const float changeStep,
        const float defaultValue
        ) = 0;

    virtual void registerEnum(
        const int id,
        const b::wchar* name,
        const int* enumValues,
        const b::wchar** enumNames,
        const b::uint32 totalValues,
        const int defaultValue
        ) = 0;

    virtual bool getBool(const int id) = 0;
    virtual void setBool(const int id, const bool value) = 0;

    virtual int getInt(const int id) = 0;
    virtual void setInt(const int id, const int value) = 0;

    virtual float getFloat(const int id) = 0;
    virtual void setFloat(const int id, const b::float32 value) = 0;

    virtual int getEnum(const int id) = 0;
    virtual void setEnum(const int id, const int value) = 0;

    virtual std::shared_ptr<journal::isetting_base> findSetting(const b::wchar* fullName) = 0;
    virtual std::shared_ptr<journal::isetting_base> findSetting(const int id) = 0;

    virtual b::int32 addObserver(const std::shared_ptr<isettings_service_observer>& observer) = 0;
    virtual void removeObserver(const std::shared_ptr<isettings_service_observer>& observer) = 0;
    virtual void removeObserver(const b::int32 cookie) = 0;

    virtual void reset() = 0;
    virtual void save() = 0;
    virtual void load() = 0;
};

} // namespace journal

#include <journal/common/settings_service_impl.hpp>